<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath }/bootstrap/css/bootstrap.min.css">  
<script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath }/js/cardId.js"></script>
<title>照片审核</title>
</head>
<body>
​<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<h3 class="text-center text-error">
				上传图片并审核
			</h3>
			<form class="form-horizontal" id="upForm" role="form" method="post" enctype="multipart/form-data" <%-- action="<%=basePath%>/upload" --%>>
				 
				 <div style="display: none;">
				 <tr>
			  				<td class="rtr">图片大小范围：</td>
			  				<td class="ltr">
				  				<input name="lageMin" value="30" class="myinput" type="text">
							  	~ <input name="lageMax" value="100"  class="myinput" type="text"> kb
						  	</td>
						</tr>
						<tr>
						  	<td class="rtr">照片宽（比例）：</td>
			  				<td class="ltr">
				  				<input name="mywidth" value="22" class="myinput" type="text">
						  	</td>
						</tr>
						<tr>
						  	<td class="rtr">照片高（比例）：</td>
			  				<td class="ltr">
				  				<input name="myheight" value="32" class="myinput" type="text">
						  	</td>
						</tr>
						<tr>
						  	<td class="rtr">人脸宽度比重（比例）：</td>
			  				<td class="ltr">
				  				<input name="fMinWidth" value="14" class="myinput" type="text">
							  	~ <input name="fMaxWidth" value="16"  class="myinput" type="text"> 
						  	</td>
						</tr>
						<tr>
						  	<td class="rtr">人脸左右最大偏差比例：</td>
			  				<td class="ltr">
				  				<input name="lrWeight" value="2" class="myinput" type="text">
						  	</td>
						</tr>
				 </div>
				 
				 <div class="form-group has-error">
				    <label class="col-sm-2 control-label" for="inputError">身份证号码</label>
				    <div class="col-sm-10">
				      <input type="text" name="zfzmhm" class="form-control" id="zfzmhm" placeholder="请输入身份证号码">
				    </div>
				  </div>
			
				<div class="form-group">
					<label for="inputError" class="col-sm-2 control-label">上传图片</label>
					<input type="file"  name="file" id="inputfile">
					<p class="control-label" style="color: red">上传驾驶人照片审核。</p>
				</div>
				<span id="error_text" style="color: red;font-size: 24px;display: none;position: absolute;left: 145px;"></span>
				<button type="button" onclick="uploadAjax()" class="btn btn-success center-block">审核</button>
			</form>
		</div>
	</div>
</div>	
</body>
<script type="text/javascript">
	
function uploadAjax(){
	
	var sfzmhm = $("#zfzmhm").val();
	if(!sfzmhm){
		$("#error_text").text("身份证号码不能为空！");
        $("#error_text").css("display","");
		return false;
	}
	/*  var result = isCardID(sfzmhm);
     if(result!= true){
	    $("#error_text").text(result);
        $("#error_text").css("display","");
	    return false;
	 } */
	
    var form = new FormData(document.getElementById("upForm"));
//     var req = new XMLHttpRequest();
//     req.open("post", "${pageContext.request.contextPath}/public/testupload", false);
//     req.send(form);
    $.ajax({
        url:"${pageContext.request.contextPath}/upload",
        type:"post",
        data:form,
        processData:false,
        contentType:false,
        success:function(data){
        	$("#error_text").text(data);
            $("#error_text").css("display","");
        },
        error:function(e){
            alert("错误！！");
        }
    });        
}


//定时任务
$(function(){  
	   window.setInterval('quxiaoText()',3000);//180秒查看一次
	});

function quxiaoText(){
	$("#error_text").text("");
    $("#error_text").css("display","none");
}
</script>
</html>